﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MyTools
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            Load += new EventHandler(Form1_Load);
        }

        void Form1_Load(object sender, EventArgs e)
        {
            Version v = new Version(Application.ProductVersion);

            StringBuilder sb = new StringBuilder();
            sb.AppendLine("------------------------------");
            sb.AppendLine("Version  :"+v.ToString());
            sb.AppendLine("------------------------------");
            sb.AppendLine("Major    : " + v.Major.ToString());
            sb.AppendLine("Minor    : " + v.Minor.ToString());
            sb.AppendLine("Build    : " + v.Build.ToString());
            sb.AppendLine("Revision : " + v.Revision.ToString());
            //sb.AppendLine("MajorRevision : " + v.MajorRevision.ToString());
            //sb.AppendLine("MinorRevision : " + v.MinorRevision.ToString());
            sb.AppendLine("------------------------------");

            textBox1.Text = sb.ToString();
            textBox1.ReadOnly = true;
        }

        #region 检测是否存在更新 //------------------------------------------------------------

        /// <summary>
        /// 含有更新信息字符串的网址
        /// <![CDATA[
        /// @"http://tangzhongxin.blog.163.com/blog/static/8921961201302325725988/";
        /// ]]>
        /// </summary>
        private const string UpdateCheckUrl = @"http://localhost:44321/MyBlog.html";

        private const string AppUniqueMark = @"A75A3EDFED144bde9F54D21A8481C594";

        private void BtnCheck1_Click(object sender, EventArgs e)
        {
            try
            {
                new Tzx.UpdateReminder.UpdateReminder(new Uri(UpdateCheckUrl), AppUniqueMark).Check();
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void BtnCheck2_Click(object sender, EventArgs e)
        {
            //new UpdateChecker().Check(new Uri(UpdateChecker.UpdateCheckUrl));
            new Tzx.UpdateReminder.UpdateReminder(new Uri(UpdateCheckUrl), AppUniqueMark).CheckAsync();
        }

        #endregion //------------------------------------------------------------


    }
}
